package com.zk.mylib

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zk.lib_service.activity.ServiceStudyActivity
import com.zk.mylib.func.activity.VideoPlayerActivity
import com.zk.mylib.ui.activity.gaofang.histogram.HistogramActivity
import com.zk.mylib.ui.activity.gaofang.youtobe.YouToBeDemoActivity

/**
 * 知识主页面
 */
class MainKnowledgeActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main_ui)
        var recyclerView = findViewById<RecyclerView>(R.id.recyclerview)
        recyclerView.layoutManager=LinearLayoutManager(this)
        var datas= mutableListOf("Service研究"
            )
        var homeAdapter = HomeAdapter(datas)
        homeAdapter.setOnItemClickListener { adapter, _, position ->
            var item = adapter.getItem(position) as String
            if(item=="Service研究"){
                startActivity(Intent(this@MainKnowledgeActivity, ServiceStudyActivity::class.java))
            }else if(item=="Histogram Demo"){
                startActivity(Intent(this@MainKnowledgeActivity, HistogramActivity::class.java))
            }


        }
        recyclerView.adapter=homeAdapter


    }
    class HomeAdapter( mutableList: MutableList<String>) : BaseQuickAdapter<String,BaseViewHolder>(R.layout.view_item_home,mutableList) {
        override fun convert(holder: BaseViewHolder, item: String) {
           holder.setText(R.id.tv_title,item)
        }

    }
}